package com.gxljc.bear.crawler.base;

import com.gxljc.commons.core.RedisUtils;
import com.gxljc.commons.redis.dao.Basegxljcedis;
import org.apache.log4j.Logger;

//获取weixin cookie
public class CookieAccount {
    private static Logger LOG = Logger.getLogger(CookieAccount.class);

    private static final CookieAccount account = new CookieAccount();
    private String weixinCookie = "";
    private String cbcomcnCookie = "";

    private CookieAccount() {
        init();
    }

    public static CookieAccount getInstance() {
        return account;
    }

    public String getWeixinCookie() {
        return weixinCookie;
    }
    public String getCbcomcnCookie() {
        return cbcomcnCookie;
    }

    //获取cookie
    private void init() {
        weixin();
        cbcomcn();
    }

    private void weixin(){
        Basegxljcedis redisDao = RedisUtils.getgxljcedisInstance();
        try {
            weixinCookie = redisDao.get(DolphinCrawlerConsts.cookieAccount.WEIXIN.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void cbcomcn(){
        Basegxljcedis redisDao = RedisUtils.getgxljcedisInstance();
        try {
            cbcomcnCookie = redisDao.get(DolphinCrawlerConsts.cookieAccount.CBCOMCN.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
